package com.bdqn.Di1Zhan;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 第一章实战2
 */
public class PersonValue {
    public static void main(String[] args) {
        try {
            Class clz = Class.forName("com.bdqn.Di1Zhan.entity.Person");

            Object obj = clz.newInstance();

            System.out.println(obj);

            Constructor c1 = clz.getDeclaredConstructor(String.class);

            c1.setAccessible(true);

            obj = c1.newInstance("何志翔");

            System.out.println(obj);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
